<?php
$this->breadcrumbs = array(
    Shop::t('Products') => array('index'),
    //$model->title,
);

echo CHtml::beginForm('/shop/shoppingCart/create','post',array('id'=>'add-to-cart'));
echo CHtml::hiddenField('product_id', $model->product_id);
?>
<!-- Please call pinit.js only once per page -->
<script type="text/javascript" async src="//assets.pinterest.com/js/pinit.js"></script>
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=155288807877390&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="sub-page">
    <h2><?php echo Category::model()->findByPk($model->category_id)->title;?></h2>
    <div class="all-product">
        <div class="prd-textt">
            <div id="content" class="prd-textt-pict">
                <span class="large-pict">
                    <a rel="example_group"
                       href="<?php echo Yii::app()->request->baseUrl ?>/data/upload/products/<?php echo isset($model->shopImages[count($model->shopImages)-1]) ? $model->shopImages[count($model->shopImages)-1]->filename : 'no_image.jpg'?>"
                       title="">
                        <img width="260" height="260" alt=""
                             src="<?php echo Yii::app()->request->baseUrl ?>/data/upload/products/<?php echo isset($model->shopImages[count($model->shopImages)-1]) ? $model->shopImages[count($model->shopImages)-1]->filename : 'no_image.jpg'?>"/></a>
                </span>
                <span class="small-pict">
                    <?php if(!empty($model->shopImages)) {
                        //foreach($model->shopImages as $index => $image) {
                        for($index=0; $index < count($model->shopImages) - 1; $index++) {
                            $image = $model->shopImages[$index];
                    ?>
                            <a rel="example_group" href="<?php echo Yii::app()->request->baseUrl ?>/data/upload/products/<?php echo $image->filename?>">
                                <img <?php if(($index+1)%2) { echo 'style="margin-right:0"';}?> width="73" height="73" alt="" src="<?php echo Yii::app()->request->baseUrl ?>/data/upload/products/<?php echo $image->filename?>"/></a>
                    <?php }
                    }?>
                </span>
                <!--
                <?php if ($data['stock']):?>
                	<span class="small-pict green-text">In Stock</span>
                <?php else :?>
                    <span class="small-pict red-text">Out of Stock</span>
                <?php endif;?>
                -->
            </div>
            <div class="prd-detail">
                <h2><?php echo $model->title ?></h2>
                <hr>
                <p class="label"><strong>Product Code:</strong> <?php echo $model->product_code?></p>

                <p class="label"><strong>Manufacturer:</strong> <?php echo $model->manufacturer?> </p>

                <p class="label"><strong>Weight:</strong> <?php echo $model->weight;?>gram</p>

                <p class="label"><strong>Size:</strong> <?php echo $model->size?>(cm)</p>

                <?php if(!empty($model->frame_id)) {?>
                <p style="margin:10px 0">
                    <span style="margin:0px 10px 0 0" class="floatL">
                        <input name="frame-included" id="frame-included" type="checkbox" value="1" checked="checked">
                    </span>
                    <span style="margin-top:2px" class="floatL">including frame <strong>(<?php echo $model->frame->name;?>)</strong></span>
                </p>
                <?php }?>

                <p class="marT20 floatL">
                    <span style="margin:7px 15px 0 0" class="floatL"><strong>Price:</strong></span>
                    <?php if ($model->price && $model->new_price) { ?>
                        <span class="old-price">$<?php echo $model->getOldPriceIncludeFrame() ?></span>
                        <span class="new-price hidden-price">$<?php echo $model->new_price?></span>
                        <span class="new-price show-price">$<?php echo $model->getPriceIncludeFrame();?></span>
                    <?php } else if ($model->price && !$model->new_price) { ?>
                        <span class="new-price hidden-price">$<?php echo $model->price?></span>
                        <span class="new-price show-price">$<?php echo $model->getPriceIncludeFrame();?></span>
                    <?php } else {?>
                        <span class="new-price">$<?php echo ($model->price)?$model->price:'' ?></span>
                    <?php } ?>
                </p>

                <p class="marT20 floatL">
                	<?php if ($model->stock):?>
	                    Add to cart:
	                    <input style="width:60px" name="amount" type="text" placeholder="1" value="1">
	                    <span class="small-pict green-text">In Stock</span>
	                <?php else :?>
	                    <span class="small-pict red-text">Out of Stock</span>
	                <?php endif;?>
                </p>

                <div class="clearB"></div>
                <?php if ($model->stock):?>
                	<a class="red-button marT20" href="javascript:{}" onclick="document.getElementById('add-to-cart').submit()">Add this to my cart</a>
                <?php endif;?>
                <div class="clearB"></div>
                           
                <div class="bt-social">
                    <div class="fb-like" data-href="https://www.facebook.com/ArtexGobelins" data-layout="button_count" data-action="like"></div>
                </div>
            </div>
            <p class="detail">
                <strong style="color:#000000">Details:</strong><br/>
                <?php echo $model->description?>
            </p>
        </div>
    </div>

</div>
<?php echo CHtml::endForm();?>
